package com.example.chessbattleplatform.web.Sys_User.CopyUtils;

import com.example.chessbattleplatform.web.Sys_User.Pojo.Vo.LoginVo;
import com.example.chessbattleplatform.web.Sys_User.Pojo.Vo.RegisterVo;
import com.example.chessbattleplatform.web.Sys_User.Pojo.dto.RegisterRequest;
import com.example.chessbattleplatform.web.Sys_User.Pojo.mapper.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring")
public abstract class CopyUser {

    @Mappings({
            @Mapping(target = "userName", source = "name"),
            @Mapping(target = "userDelete", expression = "java(false)"),
            @Mapping(target = "role", constant = "user")
    })
    public abstract User copyUser(RegisterRequest user);

    @Mapping(target = "name", source = "userName")
    public abstract LoginVo loginVo(User user);

    @Mappings({
            @Mapping(target = "name", source = "userName"),
            @Mapping(target = "email", source = "email")
    })
   public abstract RegisterVo copyRegisterVo(User user);

}
